


        var newsSwiper = new Swiper('.newsSwiper',{
            slidesPerView:4,
            spaceBetween:50,
            slidesPerGroup:4,
        })
        var prevent = false;
        var tchSt = tchEd =  0;
        $(document).ready(function(){
            function swiperFlip(now,newActv,dirctn){
                console.log('v');
                prevent = true;
                $('main .pageHead .pagination span').removeClass('active');
                $('main .pageHead .pagination span').eq(newActv).addClass('active');
                if(dirctn == undefined){
                    if(newActv > now){
                        $('main .pageHead .pic').removeClass('right');
                        $('main .pageHead .txtPic img').removeClass('right');
                        setTimeout(function(){
                            $('main .pageHead .pic').eq(newActv).addClass('active');
                            $('main .pageHead .txtPic img').eq(newActv).addClass('active');
                            $('main .pageHead .pic').eq(now).removeClass('active');
                            $('main .pageHead .txtPic img').eq(now).removeClass('active');
                        },10)
                    }else{
                        $('main .pageHead .pic').addClass('right');
                        $('main .pageHead .txtPic img').addClass('right');
                        setTimeout(function(){
                            $('main .pageHead .pic').eq(newActv).addClass('active');
                            $('main .pageHead .txtPic img').eq(newActv).addClass('active');
                            $('main .pageHead .pic').eq(now).removeClass('active');
                            $('main .pageHead .txtPic img').eq(now).removeClass('active');
                        },10)
                    }
                }else{
                    if(dirctn == 'rht'){
                        $('main .pageHead .pic').removeClass('right');
                        $('main .pageHead .txtPic img').removeClass('right');
                        setTimeout(function(){
                            $('main .pageHead .pic').eq(newActv).addClass('active');
                            $('main .pageHead .txtPic img').eq(newActv).addClass('active');
                            $('main .pageHead .pic').eq(now).removeClass('active');
                            $('main .pageHead .txtPic img').eq(now).removeClass('active');
                        },10)
                    }else{
                        $('main .pageHead .pic').addClass('right');
                        $('main .pageHead .txtPic img').addClass('right');
                        setTimeout(function(){
                            $('main .pageHead .pic').eq(newActv).addClass('active');
                            $('main .pageHead .txtPic img').eq(newActv).addClass('active');
                            $('main .pageHead .pic').eq(now).removeClass('active');
                            $('main .pageHead .txtPic img').eq(now).removeClass('active');
                        },10)
                    }
                }
                
                setTimeout(function(){
                    prevent = false;
                },1210)
            }
            for(var s = 0;s < $('main .pageHead .pagination span').length;s++){
                $('main .pageHead .pagination span')[s].ind = s;
            }
            $('main .pageHead .pagination span').click(function(){
                if(prevent) return false;
                var now = $('main .pageHead .pagination .active')[0].ind;
                var newActv = $(this).index();
                swiperFlip(now,newActv);
                
            })

            $('main .pageHead .swiper')[0].addEventListener('touchstart',touchStart,{passive:false});
            function touchStart(es){
                $('main .pageHead .swiper').attr('touching','true');
                var oEvent = es || window.event;
                tchSt = oEvent.touches[0].clientX;
                console.log('end: ' + tchSt);
            }
            document.body.addEventListener('touchend',touchEnd,{passive:false});
            function touchEnd(ee){
                if($('main .pageHead .swiper').attr('touching') == 'true'){
                    $('main .pageHead .swiper').attr('touching','false');
                    var oEvent = ee || window.event;
                    tchEd = oEvent.changedTouches[0].clientX;
                    console.log('end: ' + tchEd);
                    if(tchEd != tchSt){
                        var now = $('main .pageHead .pagination .active')[0].ind;
                        var newActv = now;
                        var dirctn;
                        if(tchEd > tchSt){
                            if(!newActv){
                                newActv = $('main .pageHead .pagination span').length - 1;
                            }else{
                                newActv--;
                            }
                            dirctn = 'lft';
                        }else if(tchEd < tchSt){
                            if(newActv == $('main .pageHead .pagination span').length - 1){
                                newActv = 0;
                            }else{
                                newActv++;
                            }
                            dirctn = 'rht';
                        }
                        swiperFlip(now,newActv,dirctn);
                    }
                }
                
                
            }

            $('main .news .swiper .btn').click(function(){
                if($(this)[0].className.indexOf('prev') >= 0){
                    newsSwiper.slidePrev();
                }else{
                    newsSwiper.slideNext();
                }
            })

            watchBrowse = setInterval(function(){
                if(window.innerWidth > 1600 && newsSwiper.params.spaceBetween != 50){
                    newsSwiper.params.spaceBetween = 50;
                    newsSwiper.update();
                }else if(window.innerWidth > 1200 && window.innerWidth <= 1600 && newsSwiper.params.spaceBetween != 35){
                    newsSwiper.params.spaceBetween = 35;
                    newsSwiper.update();
                }else if(window.innerWidth > 768 && window.innerWidth <= 1200 && newsSwiper.params.spaceBetween != 20){
                    newsSwiper.params.spaceBetween = 20;
                    newsSwiper.update();
                }else if(window.innerWidth > 1024 && newsSwiper.params.slidesPerView != 4){
                    newsSwiper.params.slidesPerView = 4;
                    newsSwiper.params.slidesPerGroup = 4;
                    newsSwiper.update();
                }else if(window.innerWidth >= 768 && window.innerWidth <= 1024 && newsSwiper.params.slidesPerView != 2){
                    newsSwiper.params.slidesPerView = 2;
                    newsSwiper.params.slidesPerGroup = 2;
                    newsSwiper.params.spaceBetween = 20;
                    newsSwiper.update();
                }else if(window.innerWidth < 768 && newsSwiper.params.slidesPerView != 1){
                    newsSwiper.params.slidesPerView = 1;
                    newsSwiper.params.slidesPerGroup = 1;
                    newsSwiper.params.spaceBetween = 0;
                    newsSwiper.update();
                }
                
            },10)
        })

        